package com.scar1et.simple.factory.factory;

import com.scar1et.simple.factory.operation.*;

/**
 * 运算工厂
 * Created by scar1et on 15-10-24.
 */
public class OperationFactory {

    public static Operation createOperation(String symbol) throws Exception {
        Operation operation = null;
        switch (symbol) {
            case "+":
                operation = new Add();
                break;
            case "-":
                operation = new Reduction();
                break;
            case "*":
                operation = new Multiplication();
                break;
            case "/":
                operation = new Division();
                break;
            default:
                throw new Exception("不支持的运算符！");
        }
        return operation;
    }
}
